package spring.cloud.tasks.executor.listener.config;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.executor.node.TaskNodePaths;


@Slf4j
@Setter
@Getter
public final class ConfigurationNode {

    public static final String ROOT = "config";

    public static final String TASK_CLASS = ROOT + "/jobClass";

    public static final String SHARDING_TOTAL_COUNT = ROOT + "/shardingTotalCount";


    public static final String CRON = ROOT + "/cron";

    public static final String PREFER_LIST = ROOT + "/preferList";

    public static final String PAUSE_PERIOD_DATE = ROOT + "/pausePeriodDate";

    public static final String PAUSE_PERIOD_TIME = ROOT + "/pausePeriodTime";

    public static final String SHARDING_ITEM_PARAMETERS = ROOT + "/shardingItemParameters";

    public static final String JOB_PARAMETER = ROOT + "/jobParameter";

    public static final String PROCESS_COUNT_INTERVAL_SECONDS = ROOT + "/processCountIntervalSeconds";

    public static final String FAILOVER = ROOT + "/failover";

    public static final String SHOW_NORMAL_LOG = ROOT + "/showNormalLog";

    public static final String DESCRIPTION = ROOT + "/description";

    public static final String TIMEOUTSECONDS = ROOT + "/timeoutSeconds";

    public static final String LOAD_LEVEL = ROOT + "/loadLevel";

    public static final String ENABLED = ROOT + "/enabled";

    public static final String ENABLED_REPORT = ROOT + "/enabledReport";

    public static final String TO_DELETE = ROOT + "/toDelete";


    public static final String USE_DISPREFER_LIST = ROOT + "/useDispreferList";

    /**
     * 作业类型: 动态写入
     */
    public static final String JOB_TYPE = ROOT + "/jobType";

    /**
     * 自定义上下文
     */
    public static final String CUSTOM_CONTEXT = ROOT + "/customContext";


    /**
     * 判断是否为作业调度配置路径.
     *
     * @param path 节点路径
     * @return 是否为作业调度配置路径
     */
    public static boolean isCronPath(final String jobName, final String path) {
        return TaskNodePaths.getTaskNodePath(jobName, CRON).equals(path);
    }

    public static boolean isEnabledPath(final String jobName, final String path) {
        return TaskNodePaths.getTaskNodePath(jobName, ENABLED).equals(path);
    }

    public static boolean isToDeletePath(final String jobName, final String path) {
        return TaskNodePaths.getTaskNodePath(jobName, TO_DELETE).equals(path);
    }


}
